package com.timemanage.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.timemanage.entity.User

@Dao
interface UserDao {

    @Query("insert into User ( useName,userPd,isActive) values (:name, :pwd,:isactive)")
    fun insertUser(name:String,pwd:String,isactive:Int):Long

    @Update
    fun updateUser(newUser:User)

    //UpdateActive
    @Query("update User set isActive=1 where useName=:loginName")
    fun UpdateActive(loginName:String)

    @Query("select * from User where userId=:userId")
    fun loadUser(userId:Int):User

    @Query("select * from User")
    fun selectUser():List<User>
    //查阅活跃用户
    @Query("select * from User where isActive=1")
    fun selectAcUser():User

    @Query("delete from User where userId=:userId")
    fun deleteUserById(userId:Int):Int

    //退出登录（消除活跃）
    @Query("update User set isActive=0 where userId=:userid")
    fun quit(userid: Int)


}